/*
 * timetools.h
 *
 *  Created on: 08/05/2014
 *      Author: simon
 */

#ifndef TIMETOOLS_H_
#define TIMETOOLS_H_

#include <time.h>

static inline void
readTime(struct timespec * now)
{
    clock_gettime(CLOCK_REALTIME, now);
}

double timeDiff(struct timespec startTime, struct timespec endTime)
{
    const double nsInSecond = 1000000000.0;


    return (double) (endTime.tv_sec - startTime.tv_sec) +
            (double) ((endTime.tv_nsec - startTime.tv_nsec) / nsInSecond);

}

#endif /* TIMETOOLS_H_ */
